package com.wksc.framework.impexp.template;

import java.io.Serializable;
import java.util.List;

/**
 * <p>
 * QueryTemplate.java
 * </p>
 * 功能描述：查询数据模板
 * 
 * @author qin jinxue
 * @date Jul 27, 2010
 */
public class QueryTemplate implements Serializable {

	private static final long serialVersionUID = -7230719471851639356L;

	/** 查询语句 */
	private String sql;

	/** 查询语句是sql为true,hql为false */
	private boolean isNative;

	/** 查询条件参数占位符 */
	private List<?> params;

	/** 存储过程的 查询条件 */
	private Object spParams;

	/** 存储过程的 总数所在的位置 */
	private int totalCountIndex = -1;

	/** 存储过程的 结果集所在的位置 */
	private int resultIndex = -1;

	/** 计算分表查询表名的开始和结束日期 */
	private String bgnTime;
	private String endTime;

	/** 计算分表查询表名的两组日期 */
	private String[] time1;// [0]开始 [1]结束日期
	private String[] time2;// [0]开始 [1]结束日期

	/** 由两个日期计算分表查询表名为true,一个日期计算为false */
	private boolean isTwoTime;

	/** 是否为分表查询 true：分表查询 flase：单个表查询 */
	private boolean isSpan = false;
	
	/**2012-5-5 zhangyan add 当前是查询报表库还是业务数据库 0=业务数据库 1=报表库
	 * 执行具体的导出操作时指定*/
	private byte currDbType = 0;

	/** 总计行 */
	protected String[] totalRow;

	/**
	 * 分表方式 1为93张分表，2为91张分表 默认值为1
	 */
	private int spanType = 1;

	/**
	 * 设置存储过程的构造方法
	 * 
	 * @param spParams
	 * @param totalCountIndex
	 *            总数所在的位置
	 * @param resultIndex
	 *            结果集所在的位置
	 */
	public QueryTemplate(Object spParams, int totalCountIndex, int resultIndex) {
		this.spParams = spParams;
		this.totalCountIndex = totalCountIndex;
		this.resultIndex = resultIndex;
	}

	public QueryTemplate(String sql, boolean isNative) {
		this.sql = sql;
		this.isNative = isNative;
	}

	public QueryTemplate(String sql, boolean isNative, List<?> parmas) {
		this.sql = sql;
		this.isNative = isNative;
		this.params = parmas;
	}

	public QueryTemplate(String sql, boolean isNative, List<?> parmas,
			String bgnTime, String endTime) {
		this.sql = sql;
		this.isNative = isNative;
		this.params = parmas;
		this.bgnTime = bgnTime;
		this.endTime = endTime;
		this.isTwoTime = false;
		this.isSpan = true;
	}

	public QueryTemplate(String sql, boolean isNative, List<?> parmas,
			String[] time1, String[] time2) {
		this.sql = sql;
		this.isNative = isNative;
		this.params = parmas;
		this.time1 = time1;
		this.time2 = time2;
		this.isTwoTime = true;
		this.isSpan = true;
	}

	public String getSql() {
		return sql;
	}

	public void setSql(String sql) {
		this.sql = sql;
	}

	public boolean isNative() {
		return isNative;
	}

	public void setNative(boolean isNative) {
		this.isNative = isNative;
	}

	public List<?> getParams() {
		return params;
	}

	public void setParams(List<?> params) {
		this.params = params;
	}

	public String[] getTotalRow() {
		return totalRow;
	}

	public void setTotalRow(String[] totalRow) {
		this.totalRow = totalRow;
	}

	public String[] getTime1() {
		return time1;
	}

	public void setTime1(String[] time1) {
		this.time1 = time1;
	}

	public String[] getTime2() {
		return time2;
	}

	public void setTime2(String[] time2) {
		this.time2 = time2;
	}

	public boolean isTwoTime() {
		return isTwoTime;
	}

	public void setTwoTime(boolean isTwoTime) {
		this.isTwoTime = isTwoTime;
	}

	public boolean isSpan() {
		return isSpan;
	}

	public void setSpan(boolean isSpan) {
		this.isSpan = isSpan;
	}

	public int getSpanType() {
		return spanType;
	}

	public void setSpanType(int spanType) {
		this.spanType = spanType;
	}

	public String getBgnTime() {
		return bgnTime;
	}

	public void setBgnTime(String bgnTime) {
		this.bgnTime = bgnTime;
	}

	public String getEndTime() {
		return endTime;
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

	public Object getSpParams() {
		return spParams;
	}

	public int getTotalCountIndex() {
		return totalCountIndex;
	}

	public int getResultIndex() {
		return resultIndex;
	}

	/**
	 * @return the currDbType
	 */
	public byte getCurrDbType() {
		return currDbType;
	}

	/**
	 * @param currDbType the currDbType to set
	 */
	public void setCurrDbType(byte currDbType) {
		this.currDbType = currDbType;
	}
	
}
